#include "InsertionSort.h"
using namespace std;
InsertionSort::InsertionSort(long v[], long n)
{
    for (long i = 0; i < n; ++i)
        this -> array[i] = v[i];
}
void InsertionSort::sort(long n)
{
    long j, aux;
	for (long i = 1; i < n; ++i)
	{
		aux = this -> array[i];
		j = i - 1;
		while (j >= 0 && aux < this -> array[j])
		{
			this -> array[j + 1] = this -> array[j];
			--j;
		}
		this -> array[j + 1] = aux;
	}
}
double InsertionSort::getExecutionTime(long n)
{
    clock_t start, end;
    start = clock();
    this -> sort(n);
    end = clock();
    return (double)(end - start) / CLOCKS_PER_SEC;
}
bool InsertionSort::Check(long n)
{
	long i;
	bool  ok = true;
	for (i = 0; i < n - 1; ++i)
		if (this -> array[i] > this -> array[i + 1])
		{
			ok = false;
			break;
		}
	cout << "\t" << i;
	return ok;
}

